/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __C377EA8A_8014_4efd_8791_FDD66DB8CEFD__
#define __C377EA8A_8014_4efd_8791_FDD66DB8CEFD__

#include "../macro/head.h"
#include "../release/head.h"
#include "i_file.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_box
{
    class i_str_property;
}

namespace xos
{

    class i_time;

    // 
    // dir interface
    // 
    class i_dir : public i_release
    {
    public:
        enum enumFileType
        {
            FILE_TYPE_NONE = 0,
            FILE_TYPE_FILE = 0x01,
            FILE_TYPE_DIR = 0x02,
            FILE_TYPE_BOTH = 0x03,
        };

    protected:
        virtual ~i_dir(){}

    public:
        //////////////////////////////////////////////////////////////////////////////////
        // 
        // get full file name path
        // 
        virtual int get_file_path( char * lpszPath, int nLen, const char * lpszFile ) = 0;

        // 
        // create dir and sub dirs
        // 
        virtual int create_directory( const char * lpszPath ) = 0;

        // 
        // delete dir and sub dirs
        // 
        virtual int delete_directory( const char * lpszPath ) = 0;

        // 
        // if a dir exists
        // 
        virtual int is_dir_exist( const char * lpszPath ) = 0;

        //////////////////////////////////////////////////////////////////////////////////

        // 
        // scan all dirs and files into property:
        // 
        //   dirs : *xos_box::i_str_property
        //   file : *i_file
        // 
        // nDepth : 
        //    -1  : no limit
        //     0  : no scan
        //  other : depth
        // 
        // if lpszPath do not exitst, *ppv is null
        // 
        virtual int scan_dir_and_files( enumFileType eType, const char * lpszExtFilter, const char* lpszPath, xos_box::i_str_property** ppv, int nDepth ) = 0;

        //////////////////////////////////////////////////////////////////////////////////

        // 
        // get file size and time
        // 
        virtual int get_file_size_and_time( const char * lpszFile, int64_t * lpSize64, int64_t * lpCreateTime, int64_t * lpAccessTime, int64_t * lpModifyTime ) = 0;

        // 
        // 设置文件时间。linux32下create time无效
        // 
        virtual int set_file_time( const char * lpszFile, int64_t cTime, int64_t aTime, int64_t mTime ) = 0;

        // 
        // if a file exists
        // 
        virtual int is_file_exist( const char * lpszFileName ) = 0;

        // 
        // delete a file
        // 
        virtual int delete_file( const char * lpszFileName ) = 0;

        // 
        // rename a file
        // 
        virtual int rename_file( const char * lpszDesName, const char * lpszSrcName ) = 0;
    };
}

#endif // __C377EA8A_8014_4efd_8791_FDD66DB8CEFD__
